:- module(general_check,
          [check_field/2],
          [hiord, assertions]).

:- use_module(db(basic_types)).
:- use_module(db(asset_access)).
:- use_module(db(certification_access)).
:- use_module(db(dictionary_access)).
:- use_module(db(organization_access)).
:- use_module(db(resource_access)).
:- use_module(db(user_access)).


check_field(Prop, Value):-
        nullify(Value),
        just_check(Prop, Value),
        !.

:- pred check_field(+Property, +Field).

just_check(nonnull, Value):- !,     \+ null(Value).
just_check(nonemptylist, Value):- !, Value = [_|_].
just_check(null, Value):- !,         null(Value).         
just_check((A, B), Value):- !,       just_check(A, Value), 
                                     just_check(B, Value).
just_check((A ; B), Value):- !,     (just_check(A,Value) ; 
                                     just_check(B,Value)).
just_check(SingleProp, Value):-      SingleProp(Value).


nullify(Value):- var(Value) -> null(Value) ; true .

%-----------------------------------------------------------

:- comment(version_maintenance,on).

:- comment(version(0*1+0,2003/07/04,12:56*36+'CEST'), "Changed
   use_module and include references to use directory aliases.  (Jesus
   Correas Fernandez)").

